home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / program / n_b_v203.zip / M_SETUP.DMO < prev    next >
Text File  |  1996-07-04  |  5KB  |  97 lines

  1. $if 0
  2.     ┌──────────────────────────╖                        PowerBASIC v3.20
  3.  ┌──┤          DASoft          ╟──────────────────────┬──────────────────╖
  4.  │  ├──────────────────────────╢    Copyright 1995    │ DATE: 1995-10-01 ╟─╖
  5.  │  │ FILE NAME   M_SETUP .DMO ║          by          ╘════════════════─ ║ ║
  6.  │  │                          ║  Don Schullian, Jr.                     ║ ║
  7.  │  ╘══════════════════════════╝                                         ║ ║
  8.  │ A license is hereby granted to the holder to use this source code in  ║ ║
  9.  │ any program, commercial or otherwise,  without receiving the express  ║ ║
  10.  │ permission of the copyright holder and without paying any royalties,  ║ ║
  11.  │ as long as this code is not distributed in any compilable format.     ║ ║
  12.  │  IE: source code files, PowerBASIC Unit files, and printed listings   ║ ║
  13.  ╘═╤═════════════════════════════════════════════════════════════════════╝ ║
  14.    │                ....................................                   ║
  15.    ╘═══════════════════════════════════════════════════════════════════════╝
  16. $endif
  17.  
  18. $INCLUDE "DAS-NB02.INC"
  19. COLOR 7, 0
  20. CLS
  21.  
  22. ? "┌────────────────────────────────────────────────────────────────
  23. ? "│ fMouseSETUP? ( ActiveButtons? )
  24. ? "├───────────────────────────────────────────────────────────────────
  25. ? "│ Actually, there are several mouse routines demonstrated here. Have
  26. ? "│ a good look at the code and the remarks for a full explanation.
  27. ? "├──────────────────────────────────────────────────────────────────────
  28. ? "│ One VERY important thing to study is the use of fGetKey% and how it can
  29. ? "│ centeralize user input, trap certain keys and/or clicks and re-route
  30. ? "│ the program from one location. In an extremely complicated program this
  31. ? "│ one function can grow to amazing size as it becomes the driving force
  32. ? "│ for everything else including the main menu! It also reduces debugging
  33. ? "│ time, can run self-operating demos, and almost anything else you can
  34. ? "│ think of.
  35. ? "└────────────────────────────────────────────────────────────────────────
  36.  
  37. COLOR 14, 0
  38. LOCATE 25, 1 : PRINT "PRESS <ALT>X OR CLICK HERE TO TERMINATE THE PROGRAM";
  39. COLOR 7, 0
  40. LOCATE 18, 50 : PRINT "┌─┐"
  41. LOCATE 19, 50 : PRINT "│ │ The mouse starts here"
  42. LOCATE 20, 50 : PRINT "└─┘"
  43. Mreport$ = "Button: ##  Row: ##  Col: ##"
  44.  
  45. Buttons? = 0                               ' use any/all buttons available
  46.                                            '   try changing to 1, 2, 3 etc.
  47.                                            '
  48. IF fMouseSETUP?( Buttons? ) = 0 THEN END   ' gotta have a mouse for this one
  49. MouseLOCATE  19, 51                        ' put the mouse where we want it
  50. MouseON                                    ' make the mouse visible
  51. DO                                         ' working loop
  52.   G% = fGetKey%                            '   wait for some user action
  53.   MouseCoffT2 16, 1, 1, 28                 '   conditional mouse off
  54.   LOCATE 16, 1                             '
  55.   IF G% = 0 THEN                           '   no key-press so it was a mouse
  56.       B% = fMouseSTATsT%( Row?, Col? )     '     get mouse status
  57.       PRINT USING Mreport$; B%, Row?, Col? '     print mouse data
  58.     ELSE                                   '
  59.       PRINT "YOU PRESSED: ";G$ SPACE$(16)  '     report key-press
  60.   END IF                                   '
  61.   MouseON                                  '   mouse visible again
  62. LOOP                                       '
  63.                                            '
  64. BYEBYE:                                    ' a graceful exit
  65.   MouseOFF                                 '  turn the mouse off
  66.   CLS                                      '  clear the screen
  67.   END                                      '  end program
  68.                                            '
  69. '════════════════════════════════════════════════════════════════════════════
  70.  
  71. FUNCTION fGetKey% () LOCAL PUBLIC
  72.   LOCAL G%, B%
  73.  
  74.   DO
  75.     IF INSTAT THEN                           ' is there a key-press waiting?
  76.         G% = CVI( INKEY$ + CHR$(0) )         '   gather it from the buffer
  77.         SELECT CASE G%                       '   anything special about it?
  78.           CASE ( 59 * 256 )                  '     F-1 call the help routine
  79.           CASE ( 45 * 256 )  : GOTO BYEBYE   '     ALT-X so end the program
  80.           CASE 124                           '     we keep "|" from the user
  81.           CASE ELSE          : EXIT LOOP     '     all other keys exit
  82.         END SELECT                           '
  83.       ELSE                                   '
  84.         B% = fMouseGetKey%                   ' was/is there any mouse action
  85.         IF B% > 0 THEN                       '   has there been a "click"
  86.           fMouseSTATsT Row?, Col?            '     get row?, col? of click
  87.           IF ( Row? = 25 ) AND _             '     exit program?
  88.              ( Col? < 52 ) THEN GOTO BYEBYE  '
  89.         END IF                               '
  90.     END IF                                   '
  91.   LOOP UNTIL B% <> 0                         '
  92.                                              '
  93.   FUNCTION = G%                              '
  94.                                              '
  95. END FUNCTION                                 '
  96.  
  97.